package cn.net.shuxing.yifu.common.front.controller;

import cn.net.shuxing.yifu.common.bean.User;
import cn.net.shuxing.yifu.common.constant.UserType;
import cn.net.shuxing.yifu.common.dto.BaseDto;
import cn.net.shuxing.yifu.common.dto.CodeConst;
import cn.net.shuxing.yifu.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseController {

    @Autowired
    private UserService userService;

    public BaseDto checkUserId(Integer userId)
    {
        User user = userService.getByPrimaryKey(userId);
        if (user == null)
        {
            BaseDto baseDto = new BaseDto();
            baseDto.setCode(CodeConst.ERROR);
            baseDto.setMsg("此用户不存在");
            return baseDto;
        }
        return null;
    }

    public boolean isStateNone(Integer userId)
    {
        return userService.getByPrimaryKey(userId).getType() == UserType.NONE;
    }
}
